package com.leather.message.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leather.common.entity.Message;
import com.leather.common.result.Result;
import com.leather.common.vo.MessageVo;
import com.leather.message.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/")
public class MessageController {

    @Autowired
    private MessageService messageService;


    @PostMapping("/send")
    public Result sendMessage(@RequestBody MessageVo messageVo) {
        return messageService.addMessage(messageVo);
    }

    @GetMapping("/getmessage")
    public Result getMessageByUserId(@RequestParam("userId") int userId, @RequestParam("pageId") int pageId) {
        Page<Message> page = new Page<>(pageId, 10);
        return messageService.getUserMessage(userId, page);
    }
}
